#include<iostream>
using namespace std;
const int N = 1e6 + 10;
int arr[N];
int n;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		int x;
		scanf("%d", &x);
		arr[x]++;
	}
	int ma = 1;
	for (int i = N; i; i--) {
		if (arr[i] >= 2) {
			ma = i;
			break;
		}
	}
	cout << ma << endl;
	return 0;
}